<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
iframe {
	background: #fff;
}
</style>
</head>
<body>
	<%-- <div id="assess" style="display: none;">
<input id="studentid" type="hidden">
<table class="layui-table">
  <thead>
    <tr>
      <th>考核项目</th>
      <th>分值</th>
      <th>得分</th>
    </tr> 
  </thead>
    <tbody>
    <c:forEach items="${data}" var="d">
    <tr>
      <td>${d.examination}</td>
      <td>${d.score}</td>
      <td><input type="text" onchange="tijiao(${d.id},this.value)" class="layui-input"></td>
    </tr>
    </c:forEach>
  </tbody>
</table>
</div> --%>
		<fieldset class="layui-elem-field layui-field-title site-title">
			<legend>
				<a name="fixbar" style="font-size: 16px; color: #ce2424;">学员成绩</a>
			</legend>
		</fieldset>
		<form class="layui-form" id="myForm" method="post"
			lay-filter="stuform">
			<div class="layui-form-item">
				<div class="layui-inline" style="width: 420px;">
					<label class="layui-form-label">班级名称：</label>
					<div class="layui-input-block">
						<select id="bjid" lay-filter="bjselect" lay-verify="required"
							lay-search>
							<c:forEach var="d" items="${data}">
								<option value="${d.id }">${d.name}</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<c:if test="${ishas}">
				<div class="layui-inline" style="width: 350px;">
					<label class="layui-form-label">是否毕业：</label>
					<div class="layui-input-block">
						<input type="checkbox" lay-filter="status" lay-skin="switch"
							lay-text="是|否">
					</div>
				</div>
			</c:if>
			</div>
		</form>
	<table id="assess_table" lay-filter="assess_table"></table>
	<script type="text/html" id="barDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="details">详情</button>
  	</div>
</script>

	<script type="text/javascript">
		layui.use('form', function() {
			var form = layui.form;
			form.render();
			
			
			form.on('switch(status)', function(obj) {
				var isstart = obj.elem.checked;	
				$("#bjid").empty();
				$.ajax({
					type : "POST",
					url : "student/banjiselect",
					data:{isstart:isstart},
					success : function(data) {
						var form = layui.form;
						var json = data;
						$("#bjid").append('<option value=""></option>');
						for (var i = 0; i < data.length; i++) {
							var json = data[i];
							var str = "";
							str += '<option value="'+json.id+'">' + json.name
									+ '</option>';
							$("#bjid").append(str);
						}
							form.render('select');
					}
				});
				
			});
			

			form.on('select(bjselect)', function(data) {
				var bjuuid = data.value;
				layui.use('table', function() {
					var table = layui.table;
					table.reload('idTest', {
						url : 'studentAssess/page',
						where : {
							bjuuid : bjuuid
						},
						page : {
							curr : 1
						//重新从第 1 页开始
						}
					});
				});
			});
		});
		layui.use('table', function() {
			var table = layui.table;
			var bjid = $("#bjid").val();
			table.render({
				elem : '#assess_table',
				url : 'studentAssess/page',
				title : "学员考核",
				id : 'idTest',
				where:{
					bjuuid:bjid
				},
				cols : [ [ {
					field : 'student',
					title : '学员',
					templet : function(d) {
						return d.student ? d.student.name : '';
					}
				}, {
					field : 'banji',
					title : '班级'
				}, {
					field : 'banjiid',
					hide:true
				}, {
					field : 'score',
					title : '总分'
				}, {
					field : 'actualscore',
					title : '分数'
				}, {
					fixed : 'right',
					title : '功能',
					align : 'center',
					toolbar : '#barDemo',
				} ] ],
				page : true
			});

			table.on('rowDouble',function(obj){
			});

			//监听表头工具事件

			/* table.on('toolbar(assess_table)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				if (obj.event === "search") {
					layer.open({
						type : 2,
						shade : false,
						shadeClose : true,
						anim : 5,
						content : 'studentAssess/search',
						area : [ '550px', '330px' ],
					});
				}
			}); */

			table.on('tool(assess_table)', function(obj) {
				
				var data = obj.data;
				if (obj.event === "details") {
					layer.open({
						type : 2,
						shade : 0.3,
						shadeClose : true,
						anim : 5,
						content : 'studentAssess/details?id=' + data.id+'&bjid='+data.banjiid,
						area : [ '550px', '330px' ],
						end : function() {
							var bjuuid = data.value;
								table.reload('idTest', {
									url : 'studentAssess/page',
									where : {
										bjuuid : bjuuid
									},
									page : {
										curr : 1
									//重新从第 1 页开始
									}
								});
						}
					});
				}
			});
		});
	</script>
</body>
</html>